package com.gxa.jd.controller.back;

import com.gxa.entity.PageResult;
import com.gxa.entity.Result;
import com.gxa.jd.pojo.UserShipping;
import com.gxa.jd.service.UserShippingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/back/userShipping")
public class UserShippingBackController {

    @Autowired
    private UserShippingService userShippingService;

    @GetMapping("/findAll")
    public List<UserShipping> findAll() {
        return userShippingService.findAll();
    }

    @GetMapping("/findPage")
    public PageResult<UserShipping> findPage(int page, int size) {
        return userShippingService.findPage(page, size);
    }

    @PostMapping("/findList")
    public List<UserShipping> findList(@RequestBody Map<String, Object> searchMap) {
        return userShippingService.findList(searchMap);
    }

    @PostMapping("/findPage")
    public PageResult<UserShipping> findPage(@RequestBody Map<String, Object> searchMap, int page, int size) {
        return userShippingService.findPage(searchMap, page, size);
    }

    @GetMapping("/findById")
    public UserShipping findById(Long id) {
        return userShippingService.findById(id);
    }


    @PostMapping("/add")
    public Result add(@RequestBody UserShipping userShipping) {
        userShippingService.add(userShipping);
        return new Result();
    }

    @PostMapping("/update")
    public Result update(@RequestBody UserShipping userShipping) {
        userShippingService.update(userShipping);
        return new Result();
    }

    @GetMapping("/delete")
    public Result delete(Long id) {
        userShippingService.delete(id);
        return new Result();
    }

}
